<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Systemconfig_model extends My_Model {

	public function __construct()
    {
        parent::__construct();
        $this->model_name="系统设置";
        $this->tablename="systemconfig";  
	}
    
    public function getsysconfig(){
       
        $query=$this->db->get($this->table_prefix.$this->tablename);
        $data=$query->result_array();

        if(!$data) return [];

        foreach ($data as $row)
        {
            $config[$row["name"]]=$row["value"];
        }        
        return $config;
    }
    
    public function get_configs()
    {
        $query=$this->db->get($this->table_prefix.$this->tablename);
        $data=$query->result_array();
        
        if(!$data) return [];
        foreach ($data as $row)
        {
            $config[$row["name"]]=$row["value"];
        }        
        return $config;
    }
    
    public function update_config($data){   
        foreach($data as $k=>$v){
            $this->db->replace($this->table_prefix.$this->tablename, array("name"=>$k,"value"=>$v));
        }
        return true;
    }
}
